Repository navigation
feat(staged): pinch to open and close note images on mobile web - #1093
Merged
Merged
Conversation
A pinch-out on an inline note or chat image now opens it in the full screen viewer, and a pinch-in from the fitted size closes it. Both follow the fingers: the picture moves between its place in the note and the fit while the viewer's backdrop and header fade with the gesture. Opening. A recogniser on the markdown container (mediaPinch.ts) takes two-finger touches where at least one finger is on an image. It prevents the moves and Safari's gesture events, so the page no longer zooms and a pinch-in no longer opens the tab overview. Once the fingers spread it mounts the viewer with the picture laid exactly over the inline image and feeds it the gesture through a new programmatic setTransform on the zoom controller. The dialog's slide animation is off on this path. On release the viewer settles at the fit, or returns the picture to the note when the pinch was let go early. Closing. The zoom controller gains an opt-in pinchDismiss option. A touch gesture that starts at the fit may go below it, unconstrained, reporting progress; on release it closes past a threshold (or on a quick pinch) and springs back to the fit otherwise. A gesture that starts zoomed in stops at the fit and never closes, so zooming back out cannot overshoot into a close. With nowhere to return to (the inline image is out of view) the picture shrinks about its centre and fades. Only the image viewer turns the option on; the diagram viewer and the wheel behaviour are unchanged. Tap and the expand button still open the viewer with the usual animation. The research note suggested `touch-action: pan-x pan-y` on the figure. It is deliberately not used: in Mobile Safari on the iOS 27.2 simulator it stopped a one-finger drag that starts on the image from scrolling the note, and preventing the events is enough to hold page zoom at 1.00x. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ages Follow-up to the pinch-to-open and pinch-to-close work, applying its review and three behaviour changes. Review findings: - A cancelled touch sequence no longer closes the viewer. d3-zoom sends touchcancel down the same path as touchend, so a system interruption while the picture was below the close ratio closed it. The zoom controller now reports onRelease(false) for a touchcancel, matching the opening recogniser. - The opening recogniser can no longer be left holding a gesture. Touch events stay with the element a finger landed on, so the end of a sequence never reached the container when one finger was outside it, or when the touched element was removed mid-gesture; the next one-finger drag then had every move prevented and did not scroll. Once two fingers are down the recogniser now follows the sequence on the touch targets themselves as well, and a touchstart that carries none of the fingers it was tracking starts afresh. - A pinch close to an inline image that is only partly in view no longer lands the picture on top of whatever covers the rest (the note header, the chat composer). visibleImagePlace reports the area the image shows through, and the viewer closes a clip in to it while the picture settles. Behaviour: - A pinch-in that starts zoomed in meets a rubber band at the fitted size instead of a hard stop: the picture gives up to a fifth of the fit, with growing resistance, and springs back on release. It still never closes within that gesture. d3-zoom keeps the scale the fingers ask for; only the transform reported to the viewer resists. - An opening pinch carried past the fitted size stays at the scale under the fingers on release, as a zoom in the open viewer would, instead of snapping back to the fit. The new settleTransform on the controller brings the placement within the scale limit (about the fingers) and the content constraint. Released short of the fit it still goes on to the fit. Tests: a MediaViewerModal component test covers where the picture goes when a pinch ends (back to the image, clipped, shrink and fade with nowhere to return to, cancelled, and the opening outcomes), alongside unit tests for the rubber band, touchcancel, settleTransform and the recogniser's stuck states. Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On mobile web, a pinch-out on an inline note or chat image now opens it in the full screen viewer, and a pinch-in from the fitted size closes it. Both follow the fingers: the picture moves between its place in the note and the fit while the viewer's backdrop and header fade with the gesture.
Opening
mediaPinch.ts) takes two-finger touches where at least one finger is on an image. It prevents the moves and Safari's gesture events, so the page no longer zooms and a pinch-in no longer opens the tab overview.setTransformon the zoom controller. The dialog's slide animation is off on this path.settleTransform).Closing
pinchDismissoption, turned on only by the image viewer. A touch gesture that starts at the fit may go below it, reporting progress; on release it closes past a threshold (or on a quick pinch) and springs back to the fit otherwise.touchcancel) does not close the viewer.Unchanged
The diagram viewer and wheel zoom behave as before. Tap and the expand button still open the viewer with the usual animation.
touch-action: pan-x pan-yon the figure is deliberately not used: in Mobile Safari on the iOS 27.2 simulator it stopped a one-finger drag that starts on the image from scrolling the note, and preventing the events is enough to hold page zoom at 1.00x.Tests
mediaPinch.test.ts: the opening recogniser, including its stuck states.diagramZoom.test.ts: pinch dismiss, the rubber band,touchcancel,setTransformandsettleTransform.MediaViewerModal.component.test.ts: where the picture goes when a pinch ends (back to the image, clipped, shrink and fade, cancelled, and the opening outcomes).🤖 Generated with Claude Code